package role

import (
	"parking-lot-go-admin/controller"
	"parking-lot-go-admin/model"
	"parking-lot-go-admin/model/admin"

	"github.com/gin-gonic/gin"
)

func RoleAll(c *gin.Context) {

	//查询信息
	var adminGroupStruct admin.AdminGroupStruct
	var adminGroupData []admin.AdminGroupStruct
	model.GetModelData(
		model.Db,
		adminGroupStruct.TableName(),
		&adminGroupData,
		model.QueryOptions{
			Conditions: map[string]interface{}{
				"status": 1,
			},
			OrderBy: "id desc",
			Debug:   true,
		},
	)

	//数据格式化
	returnData := make([]map[string]interface{}, 0)
	for _, v := range adminGroupData {
		returnData = append(returnData, map[string]interface{}{
			"id":   v.Id,
			"name": v.Name,
		})
	}

	controller.Success(c, returnData)
}
